<template>
  <div class="commentReply">
    <div class="cmt_floor">
      <Mycomment v-if="item.parent" :item="item.parent" @sendComment="sendComment" />
      <div class="floor_info">
        <div class="floor_info_left">
          <img
            :src="$axios.defaults.baseURL + item.account.defaultAvatar"
            alt=""
          />&nbsp;
          {{ item.account.nickname }} &nbsp;&nbsp;&nbsp;
          <span>2019-12-11 2:46</span>
        </div>
        <div class="floor_info_right">{{ item.level }}</div>
      </div>
      <div class="floor_content">
        <div
          class="main_content"
          @mouseenter="isshow = !isshow"
          @mouseleave="isshow = !isshow"
        >
          {{ item.content }}
          <div class="pic_content">
            <div v-for="(item, index) in item.pics" :key="index" class="pics">
              <div class="demo-image__preview">
                <el-image
                  style="width: 80px; height: 80px"
                  :src="$axios.defaults.baseURL + item.url"
                  :preview-src-list="[$axios.defaults.baseURL + item.url]"
                >
                </el-image>
              </div>
            </div>
          </div>
          <div class="cmt_reply">
            <a href="javascript:;" v-show="isshow" @click="sendComment(item)">回复</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Mycomment",
  props: ["item"],

  data() {
    return {
      isshow: false,
    };
  },

  methods: {
    sendComment(item) {
      this.$emit("sendComment", item)
    }
  },
};
</script>

<style lang="less" scoped>
.commentReply {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 10px;
  .cmt_floor {
    padding: 10px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    .floor_info {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: #666;
      margin-bottom: 10px;
      margin-top: 5px;
      padding: 0 10px;
      .floor_info_left {
        > img {
          width: 25px;
          height: 25px;
          vertical-align: middle;
        }
        > span {
          color: #999;
        }
      }
    }
    .floor_content {
      padding: 0 10px;
      margin-bottom: 20px;
      .main_content{
        margin-left: 35px;
        background-color: #fff;
        border-radius: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
        padding: 5px 10px 5px;
        font-size: 14px;
      }
      .pic_content {
        display: flex;
        .pics {
          width: 92px;
          height: 92px;
          margin-top: 10px;
          padding: 5px;
          box-sizing: border-box;
          border-radius: 6px;
          border: 1px dashed #ddd;
          margin-right: 5px;
          img {
            display: block;
            width: 100%;
            height: 100%;
            cursor: pointer;
            object-fit: cover;
          }
        }
      }
      .cmt_reply {
        height: 20px;
        line-height: 20px;
        font-size: 12px;
        color: #1e50a2;
        text-align: right;
      }
    }
  }
}
</style>